<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
	require_once("connect.php");
	$kelompok='Modul';
	$query_id_pertanyaan = "SELECT ID,jenis FROM pertanyaan WHERE kelompok='$kelompok'";
	$hasil_id=mysql_query($query_id_pertanyaan);
	while($row_hasil=mysql_fetch_row($hasil_id)){
		$name = "Pertanyaan_".$row_hasil[0];
		$respon = $_POST[$name];
		if($row_hasil[1]==1){
			$query_input_respon = "UPDATE pilihan SET jum_poll=jum_poll+1 WHERE pilihan_alias='$respon'";
			$query = mysql_query($query_input_respon);	
		}else if($row_hasil[1]==2){
			$query_pilihan = "SELECT pilihan_alias FROM pilihan WHERE ID = '$row_hasil[0]'";
			$hasil_query = mysql_query($query_pilihan);
			while($row = mysql_fetch_row($hasil_query)){
				if(isset($_POST[$row[0]])){
					$query = mysql_query("UPDATE pilihan SET jum_poll=jum_poll+1 WHERE pilihan_alias='$row[0]'");	
				}
			}
		}else if($row_hasil[1]==3){
			$query_insert_jawaban = "INSERT INTO jawaban(ID, jawaban) VALUES ('$row_hasil[0]','$respon')";
			$query = mysql_query($query_insert_jawaban);		
		}
	}
	echo "<h1 align='center'>TERIMA KASIH TELAH MENGISI POLING INI</h1>\n";
?>
</body>
</html>